//
//  BKSettingViewController.m
//  I'm BKer
//
//  Created by Nguyen Van Hoa on 5/14/13.
//  Copyright (c) 2013 vanhoavn. All rights reserved.
//

#import "BKSettingViewController.h"

@interface BKSettingViewController ()

@end


@implementation BKSettingViewController

@synthesize txtMSSV;
- (id)init
{
    return [self initWithNibName:@"BKSettingViewController" bundle:nil];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"Cài đặt";
        self.tabBarItem.image = [UIImage imageNamed:@"first"];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.txtMSSV.text = [BKStudentManager mssv];
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if([BKStudentManager requireMSSV]){
        [self.txtMSSV becomeFirstResponder];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
- (IBAction)reloadData:(id)sender
{
    if(![BKStudentManager requireMSSV])
    {
        [BKLoadingViewController presentInViewController:self];
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSString* currMS = [textField text];
    NSLog(@"curr %@ %d",currMS,[BKStudentManager validateMSSV:currMS]);
    if([BKStudentManager validateMSSV:currMS])
    {
        [BKStudentManager setMSSV:currMS];
        [textField resignFirstResponder];
        [BKLoadingViewController presentInViewController:self];
    }else{
        
    }
    return NO;
}

@end
